Conversation
ElementalBrian
approved these changes
Apr 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Global RPC Fallback for MrOracle
3-layer JSON-RPC fallback (primary → backup → public) covering every RPC call MrOracle makes, plus correctness fixes found during audit.
Problem
MrOracle used a single RPC endpoint with no failover. When it goes down, oracle price updates silently stop. No prices pushed on-chain, which blocks all user position operations (close, SL, TP etc).
Solution
3-layer JSON-RPC fallback (primary → backup → public) covering ALL RPC operations:
Per endpoint: get blockhash → sign → send → confirm (4 polls @ 500ms, up to 2s). On-chain errors short-circuit the chain (no retry on backup/public for deterministic failures).
Stateless — each RPC call starts fresh from primary. If primary recovers, the very next call hits it first. No circuit breaker, no stickiness.
CLI args
--rpc(renamed from--endpoint) — primary JSON-RPC endpoint--rpc-backup— optional backup RPC endpoint--rpc-public— last-resort public RPC (defaults toapi.mainnet-beta.solana.com)Bug fixes (audit findings)
--commitmentactually plumbed through: the CLI arg was parsed but ignored, so--commitment processedgave users default (finalizedorconfirmed) behavior. Now flows through toRpcClient::new_with_timeout_and_commitment(). Affects blockhash freshness, tx confirmation polling, and account reads.percentileparam was a server-side extension that doesn't work on public RPCs). Computes percentiles client-side.sign_and_sendno longer retries deterministic on-chain errors across endpoints, preventing priority fee waste.periodical_priority_fees_fetching_task.take().abort()no-op that always ran on freshly-initialized None.get_signature_statusestimeout: wrapped in explicittokio::time::timeoutfor predictable per-endpoint worst-case timing.What's NOT touched
let _ =non-blocking error handling in the main loop (service never crashes on total RPC failure)updatePoolAuminstruction structure (raw Vec build produces byte-identical tx vs anchor RequestBuilder)Usage
--rpc https://primary-rpc.example.com/
--rpc-backup https://backup-rpc.example.com/
--rpc-public https://api.mainnet-beta.solana.com
Without
--rpc-backup: primary → public. With it: primary → backup → public.